#include "ShapeNode.h"

namespace scenegraph
{

	//==============//
	// CONSTRUCTORS //
	//==============//
	//TO DO: must be placed in cpp file
	ShapeNode::ShapeNode() : r(0), g(0), b(0), alpha(0)
	{
		//default constructor
	}
	ShapeNode::ShapeNode(int ARGBvalues)
	{
		setColor(ARGBvalues);
	}
	ShapeNode::ShapeNode(int rVal, int gVal, int bVal, int alpha)
	{
		setColor(rVal, gVal, bVal, alpha);
	}
	ShapeNode::ShapeNode(int colors[], int alpha)
	{
		setColor(colors, alpha);
	}

	//===================//
	// GET / SET METHODS //
	//===================//
	void ShapeNode::setColor(int colors[3], int _alpha)
	{
		r = colors[0];
		g = colors[1];
		b = colors[2];
		alpha = _alpha;
	}
	
	/**
	* This function takes in values in the following
	* order: A - Alpha, R - Red, G - Green, B - Blue
	*	0xAARRGGBB
	*/
	void ShapeNode::setColor(int RGBAvalues)
	{
		alpha = (RGBAvalues >> 24)  & 0x000000FF;
		r	  = (RGBAvalues >> 16)  & 0x000000FF;
		g	  = (RGBAvalues >> 8)   & 0x000000FF;
		b	  = (RGBAvalues >> 0)   & 0x000000FF;
		updateTransform();
	}
	void ShapeNode::setColor(int rVal, int gVal, int bVal, int _alpha)
	{
		r = rVal;
		g = gVal;
		b = bVal;
		alpha = _alpha;
		updateTransform();
	}

	ShapeNode::~ShapeNode() {
	  // Allow subclass destructors to be called
	}

	void ShapeNode::draw() {
	  glPushMatrix();
	  glMultMatrixf( transform );
	}

	void ShapeNode::drawFinish() {
	  glPopMatrix();
	};
}